#include<bits/stdc++.h>
using namespace std;
struct node
{
    int d,v,a;
}car[100005];
int p[100005];
set<int> s;
bool cmp(node a,node b)
{
    return a.d<b.d;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
	int T;
	cin>>T;
	while(T--)
	{
        int ans1=0,ans2=0;
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        memset(car,0,sizeof(car));
        memset(p,0,sizeof(p));
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&car[i].d,&car[i].v,&car[i].a);
        }
        sort(car+1,car+1+n,cmp);
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&p[i]);
        }
        cout<<ans1<<" "<<ans2<<endl;
	}
    return 0;
}
